<?php

Class AutocompleteHelper extends AppHelper
{

	function generateOutput($selector,$options)
	{
		$this->initHelper('Html');
		$this->addFiles();
		$url = $options['url'];
		unset($options['url']);
		$this->initHelper('Javascript');
		$optionJson = $this->Javascript->object($options);
		$selector = addslashes($selector);
		$url = addslashes($url);
		$block ="var option = $optionJson ;\n applyAutoComplete('$selector','$url',option);";
		$this->addJqBlock($block);
			
	}
	function addFiles()
	{
		$view = ClassRegistry::getObject('view');
		$this->initHelper('Html');
		$this->initHelper('Javascript');
		$this->Html->css('/cms/css/jquery.autocomplete.css',null,array(),false);
		$this->Javascript->link('/cms/js/jquery.autocomplete.js',false);
	}
}

?>